package com.atguigu.yygh.hosp.controller.api;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.hosp.service.DepartmentService;
import com.atguigu.yygh.hosp.service.HospitalService;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.DepartmentVo;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author jiaoyanlin
 * @Date 2021/9/7 14:23
 * @Description HospitalApiController
 */
@Api(tags = "医院显示接口")
@RestController
@RequestMapping("/api/hosp/hospital")
public class HospitalApiController {
    @Autowired
    private HospitalService hospitalService;
    @Autowired
    private DepartmentService departmentService;
    //条件查询 获取医院列表
    @ApiOperation(value = "获取医院列表")
    @GetMapping("getHospList")
    public R getHospList(HospitalQueryVo hospitalQueryVo) {
      List<Hospital> list =  hospitalService.selectHospList(hospitalQueryVo);
        return R.ok().data("list",list);
    }
    //模糊查询
    @ApiOperation(value = "根据医院名称获取医院列表")
    @GetMapping("findByHosname/{hosname}")
    public R findByHosname(
            @PathVariable String hosname) {
        List<Hospital> list = hospitalService.getHospName(hosname);
        return R.ok().data("list",list);
    }
    //根据医院编号查询医院详情
    @ApiOperation(value = "医院预约挂号详情")
    @GetMapping("getHosp/{hoscode}")
    public R getHosp(@PathVariable String hoscode){
        Map<String,Object> map =hospitalService.getHosp(hoscode);
         return R.ok().data(map);
    }
    //根据医院编号获取医院科室
    @ApiOperation(value = "获取科室列表")
    @GetMapping("department/{hoscode}")
    public R index(@PathVariable String hoscode) {

        List<DepartmentVo> list = departmentService.findDeptTree(hoscode);
        return R.ok().data("list",list);
    }
}
